<template>
	<view class="container">
		<Navigation />
		<view class="news-list">
			<NewsItem v-for="item in newsItems" :key="item.id" :item="item" @click="goToDetail(item.id)" />
			<!-- 假设每个新闻项传递了item对象 -->
		</view>
	</view>
</template>

<script>
	import Navigation from '../../components/Navigation.vue';
	import NewsItem from '../../components/NewsItem.vue';

	export default {
		components: {
			NewsItem,
			Navigation
		},
		data() {
			return {
				newsItems: [{
						id: 1,
						title: '新闻标题1',
						summary: '新闻摘要1'
					},
					{
						id: 2,
						title: '新闻标题2',
						summary: '新闻摘要2'
					},
					{
						id: 3,
						title: '新闻标题3',
						summary: '新闻摘要3'
					},
					{
						id: 4,
						title: '新闻标题4',
						summary: '新闻摘要4'
					},
					{
						id: 5,
						title: '新闻标题5',
						summary: '新闻摘要5'
					},
				]
			};
		},
		methods: {
			goToDetail(newsId) {
				// 使用uni.navigateTo进行页面跳转，并传递新闻ID
				uni.navigateTo({
					url: `/pages/detail/detail?id=${newsId}`
				});
			}
		}
	}
</script>

<style scoped>
	.container {
		padding: 20px;
	}

	.news-list {
		margin-top: 10px;
	}
</style>